#include "./../inc/main.h"

map_p prev_map = NULL; // 上一个地图
map_p curr_map = NULL; // 当前地图
per_p per = NULL;      // 玩家
int map_index = 0;
char *map_path[10] = {"/map.txt", "/map1.txt", "/map2.txt"};
monster_Node_p monster_head;

int main()
{
    enableANSISupport(); // 解决终端乱码
    monster_head = monsterInit();
    // 加载人物地图

    per = (per_p)malloc(sizeof(per_t));

    int status = load_per();
    if (status == 0)
    {
        // ensureDirectoryExists("./res");
        curr_map = mapInit();
    }
    else
    {
        map_index = per->map;
        curr_map = load_map(); // 加载地图
        curr_map->map[per->loc[0]][per->loc[1]] = PLAYER;
    }

    chess(curr_map);

    while (1)
    {
        int status = move(per);
        if (status == 0)
        {
            break;
        }
    }
}